#ifndef _PARAMETER__PARAMETERS_H_
#define _PARAMETER__PARAMETERS_H_

#include <stdint.h>

//TODO: use some macro for convinient
#define PARAM_DEFINE(name, type) [name] = {#name, type, (void *)0}
#define PARAM_ASSIGN(name, ptype, var) \
	g_parameters[name].type = ptype;	\
	g_parameters[name].val_ptr = (void *)(&var)

/* parameter's name must be the same with the enum name*/

enum param_index {
	ROLL_RATE_P = (uint16_t)0,
	ROLL_RATE_I,
	ROLL_RATE_D,
	PITCH_RATE_P,
	PITCH_RATE_I,
	PITCH_RATE_D,
	YAW_RATE_P,
	YAW_RATE_I,
	YAW_RATE_D,
	RC_CH1_MIN = (uint16_t)9,
	RC_CH1_MAX,
	RC_CH1_MID,
	RC_CH2_MIN,
	RC_CH2_MAX,
	RC_CH2_MID,
	RC_CH3_MIN,
	RC_CH3_MAX,
	RC_CH3_MID,
	RC_CH4_MIN,
	RC_CH4_MAX,
	RC_CH4_MID,
	MAG_SCALE_X,
	MAG_SCALE_Y,
	MAG_SCALE_Z,
	MAG_OFFSET_X,
	MAG_OFFSET_Y,
	MAG_OFFSET_Z,
	ACC_SCALE_X,
	ACC_SCALE_Y,
	ACC_SCALE_Z,
	ACC_OFFSET_X,
	ACC_OFFSET_Y,
	ACC_OFFSET_Z
};

enum param_type {
        PARAM_INT32 = 0,
        PARAM_FLOAT,
	PARAM_UINT16
};

struct param_s {
        char *name;
        uint8_t type;
        void *val_ptr;
};

uint8_t param_save(enum param_index paramIdx);
uint8_t param_load(enum param_index paramIdx);
uint16_t param_load_all(void);
uint8_t param_load_one_by_one(void);

extern struct param_s g_parameters[];

#endif
